package usually;

public class _静态函数和非静态函数_ {
    public static void main(String[] args) {
        String country = Person.country;
        System.out.println(country);
        Person p1 = new Person("jack",20,"Man");
        Person p2 = new Person("warren",25,"Man");
        p2.speak();
        p1.country = "US";
        p1.speak();

    }

}

class Person{
    String name;
    int age;
    String gender;

    static  String country = "CN";
    static {
        System.out.println("这是静态代码块");
    }
    {
        System.out.println("这是构造代码块");
    }
    Person() {
        System.out.println("无参数构造");
    }
    Person(String name,int age, String gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        System.out.println("有参数构造");
    }
    //非静态方法
    void speak() {
        System.out.println("国籍：" + country);
        System.out.println("国籍：" + country + "姓名："+ name + "性别:" + gender + "年龄："+ age);
        //非静态方法可以调用静态方法
        run();
    }
    //静态方法
    static void run() {
        System.out.println("国籍：" + country);
    }

}
